import 'package:flutter/material.dart';

class MyApp2 extends StatefulWidget {
  const MyApp2({super.key});

  @override
  State<MyApp2> createState() => _MyApp2State();
}

class _MyApp2State extends State<MyApp2> {
  // 年龄状态
  int age = 18;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('有状态组件'),
        backgroundColor: Colors.purple,
      ),
      body: Center(
        child: Text(
          '我叫朱丽叶, 今年$age岁',
          style: const TextStyle(color: Colors.red, fontSize: 20.0),
        ),
      ),
    );
  }
}

